const path = require('path');
const merge = require('webpack-merge');
const config = require('./webpack.base');
const webpack = require('webpack');

process.env.BABEL_ENV = 'client';

const clientConfig = {
  mode: 'development',
  entry: './src/client/index.js',
  output: {
    filename: 'index.js',
    path: path.resolve(__dirname, 'public')
  },
  plugins: [
    new webpack.DefinePlugin({
      '__SERVER__': false
    })
  ],
  module: {
    rules: [
      {
        test: /\.css?$/,
        use: [
          'style-loader',
          {
            loader: 'css-loader',
            options: {
              importLoaders: 1,
              modules: {
                //localIdentName定义的是生成的css类名, name是css的原文件名, local是你使用本来的css类名
                localIdentName: '[path][name]_[local]_[hash:base64:5]'
              }
            }
          }
        ]
      }
    ]
  }
};

module.exports = merge(config, clientConfig);
